package com.kan.awaits.mongo.annotations;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * @author Elva
 * @date 2011-4-13
 */
@Retention(RetentionPolicy.RUNTIME)
@Target( { ElementType.METHOD, ElementType.FIELD })
public @interface Reference
{
	/**
	 * 引用联级,默认为NONE,你需要对被依赖的数据进行修改
	 * 
	 * @author Elva
	 * @date 2011-4-14
	 * @version 1.0
	 */
	public static enum ReferenceCascade
	{
		ALL, SAVE, UPDATE, DELETE, NONE
	}

	String value() default "";// 属性名称, 所依赖的Collection名称

	Collection referenceCollection() default @Collection(automaticallyGenerate = false);// 所依赖的集合,默认为属性类型定义的

	/** Ignore any reference that don't resolve (aren't in mongodb) */
	boolean ignoreMissing() default false;//

	/** Create a proxy around the reference which will be resolved on the first method call. */
	boolean lazy() default true;

	ReferenceCascade[] cascade() default ReferenceCascade.NONE;
}
